// 1. javascript 有好几种二进制格式：
// - ArrayBuffer: 原始二进制数据
// - DataView
// - Blob
// - File
// 上面几种都是以非标准方式实现

function concat(arrays) {
  let byteLength = arrays.reduce(
      (prev, item) =>  prev + item.byteLength,
      0
  )
  let view = new Uint8Array(byteLength)
  arrays.forEach((arr, index) => {
    view.set(arr, 3*index)
  })
  return view
}

let chunks = [
  new Uint8Array([0, 1, 2]),
  new Uint8Array([3, 4, 5]),
  new Uint8Array([6, 7, 8])
]
console.log(Array.from(concat(chunks))) // 0, 1, 2, 3, 4, 5, 6, 7, 8
console.log(concat(chunks).constructor.name); // Uint8Array
